import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:laos_mall/common/style/app_style.dart';
import 'package:laos_mall/common/style/extension_util.dart';
import 'package:laos_mall/common/widght/appbar_widget.dart';
import 'package:laos_mall/common/widght/item_widget.dart';

import '../../main/config.dart';
import 'logic.dart';

class PointDetailPage extends StatelessWidget {
  PointDetailPage({Key? key}) : super(key: key);

  final logic = Get.put(PointDetailLogic());

  @override
  Widget build(BuildContext context) {
    return Obx(() {
      return Scaffold(
      appBar: AppBarWidget(text: "point_shop".tr),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [

          Swiper(itemCount: 4, itemBuilder: (context, index) {
            return Image.asset(
              "img1.jpeg".toImgPath(directory: 'test_img'), fit: BoxFit.cover,);
          },).addContainer(height: ScreenUtil().screenWidth - 40.w,
              width: ScreenUtil().screenWidth - 40.w,
              color: Colors.transparent,
              margin: EdgeInsets.symmetric(vertical: 16.h)),
          Text("Mid-waist Flared Jeans   Mid-waist Flared Jeans   Mid-waist",
            style: AppStyle.textStyle,),
          Text("${Config.symbol}400",
            style: AppStyle.subtitleLightStyleGray.copyWith(
                decoration: TextDecoration.lineThrough),).addPadding(
              EdgeInsets.symmetric(vertical: 12.h)),
          Row(children: [
            ItemWidget(prefixItem: Image.asset(
              'ic_sanbin'.toImgPath(), width: 18.w, height: 18.w,),
              suffixItem: "999",
              space: 4,
              isReverse: true,),
            Spacer(),
            Text("VALIDITY PERIOD: 3 MONTHS",
              style: AppStyle.subtitleLightStyleGray,)
          ],).addPadding(EdgeInsets.only(bottom: 15.h)).addDiver(),

          _buildContent('product_des'.tr,
              Text("Details  Content", style: AppStyle.textStyleLight,))
        ],).addSingleChildScrollView().addPadding(
          EdgeInsets.symmetric(horizontal: 20.w)),
      bottomNavigationBar: Container(
        color: Colors.white, height: 60.w + 27.w, child:
      Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Stack(
            children: [
              Positioned(left: 8,
                top: 8,
                child: Text("available_points".tr,
                  style: AppStyle.textSmallStyleLightGray,),),
              Align(alignment: Alignment.center, child:
              ItemWidget(prefixItem: Image.asset(
                'ic_sanbin'.toImgPath(), width: 11.w, height: 11.w,),
                suffixItem: "999",
                space: 4,
                isReverse: true,
                mainAxisAlignment: MainAxisAlignment.center,))
            ],)
              .addContainer(height: 60.w, color: Colors.transparent)
              .addExpand(),
          AppButton.fullBtn(()=>logic.confirmExchange("31"), "confirm_exchange".tr,
              style: AppButtonStyle.normal,
              padding: EdgeInsets.zero,
              size: Size(double.infinity, 60.h),
              isEnable: logic.isExchange.value).addExpand(),
        ],
      ).addContainer(height: 60.w,
          color: Colors.transparent,
          border: AppStyle.roundBorderExt(borderColor: AppColor.dividerColor))
        ,),
      );
    });
  }

  _buildContent(String title, Widget content) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(title),
        SizedBox(height: 16.h,),
        content,
      ],).addContainer(color: Colors.transparent,
        margin: EdgeInsets.only(top: 12.h),
        width: double.infinity);
  }


}
